package com.tomdd.controller;

import com.tomdd.task.ScheduleTask;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zx
 * @date 2025年04月18日 14:15
 */
@RestController
@RequestMapping("/test")
@AllArgsConstructor
@Slf4j
public class TestController {

    private final ScheduleTask scheduleTask;

    @GetMapping("/info")
    public String testInfo(){
        return "success test info";
    }

    @GetMapping("/updateCron")
    public String update(String cron){
        log.info("new Cron(cron表达式) :{}",cron);
        scheduleTask.setCron(cron);
        return "success";
    }

    @GetMapping("/updateTime")
    public String updateTime(Long timer){
        log.info("new timer(毫秒) :{}",timer);
        scheduleTask.setTimer(timer);
        return "success";
    }

}
